﻿using System;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x0200000D RID: 13
	[HelpURL("http://www.root-motion.com/finalikdox/html/page2.html")]
	[AddComponentMenu("Scripts/RootMotion.FinalIK/IK/Biped IK")]
	public class BipedIK : SolverManager
	{
		// Token: 0x0600011D RID: 285 RVA: 0x00002E0C File Offset: 0x0000100C
		[ContextMenu("User Manual")]
		public void OpenUserManual()
		{
			Application.OpenURL("http://www.root-motion.com/finalikdox/html/page2.html");
		}

		// Token: 0x0600011E RID: 286 RVA: 0x00002E18 File Offset: 0x00001018
		[ContextMenu("Scrpt Reference")]
		public void OpenScriptReference()
		{
			Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_biped_i_k.html");
		}

		// Token: 0x0600011F RID: 287 RVA: 0x00002E24 File Offset: 0x00001024
		[ContextMenu("Support Group")]
		public void SupportGroup()
		{
			Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik");
		}

		// Token: 0x06000120 RID: 288 RVA: 0x00002E30 File Offset: 0x00001030
		[ContextMenu("Asset Store Thread")]
		public void ASThread()
		{
			Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/");
		}

		// Token: 0x06000121 RID: 289 RVA: 0x00002E3C File Offset: 0x0000103C
		public float GetIKPositionWeight(AvatarIKGoal goal)
		{
			return this.GetGoalIK(goal).GetIKPositionWeight();
		}

		// Token: 0x06000122 RID: 290 RVA: 0x00002E4A File Offset: 0x0000104A
		public float GetIKRotationWeight(AvatarIKGoal goal)
		{
			return this.GetGoalIK(goal).GetIKRotationWeight();
		}

		// Token: 0x06000123 RID: 291 RVA: 0x00002E58 File Offset: 0x00001058
		public void SetIKPositionWeight(AvatarIKGoal goal, float weight)
		{
			this.GetGoalIK(goal).SetIKPositionWeight(weight);
		}

		// Token: 0x06000124 RID: 292 RVA: 0x00002E67 File Offset: 0x00001067
		public void SetIKRotationWeight(AvatarIKGoal goal, float weight)
		{
			this.GetGoalIK(goal).SetIKRotationWeight(weight);
		}

		// Token: 0x06000125 RID: 293 RVA: 0x00002E76 File Offset: 0x00001076
		public void SetIKPosition(AvatarIKGoal goal, Vector3 IKPosition)
		{
			this.GetGoalIK(goal).SetIKPosition(IKPosition);
		}

		// Token: 0x06000126 RID: 294 RVA: 0x00002E85 File Offset: 0x00001085
		public void SetIKRotation(AvatarIKGoal goal, Quaternion IKRotation)
		{
			this.GetGoalIK(goal).SetIKRotation(IKRotation);
		}

		// Token: 0x06000127 RID: 295 RVA: 0x00002E94 File Offset: 0x00001094
		public Vector3 GetIKPosition(AvatarIKGoal goal)
		{
			return this.GetGoalIK(goal).GetIKPosition();
		}

		// Token: 0x06000128 RID: 296 RVA: 0x00002EA2 File Offset: 0x000010A2
		public Quaternion GetIKRotation(AvatarIKGoal goal)
		{
			return this.GetGoalIK(goal).GetIKRotation();
		}

		// Token: 0x06000129 RID: 297 RVA: 0x00002EB0 File Offset: 0x000010B0
		public void SetLookAtWeight(float weight, float bodyWeight, float headWeight, float eyesWeight, float clampWeight, float clampWeightHead, float clampWeightEyes)
		{
			this.solvers.lookAt.SetLookAtWeight(weight, bodyWeight, headWeight, eyesWeight, clampWeight, clampWeightHead, clampWeightEyes);
		}

		// Token: 0x0600012A RID: 298 RVA: 0x00002ECD File Offset: 0x000010CD
		public void SetLookAtPosition(Vector3 lookAtPosition)
		{
			this.solvers.lookAt.SetIKPosition(lookAtPosition);
		}

		// Token: 0x0600012B RID: 299 RVA: 0x00002EE0 File Offset: 0x000010E0
		public void SetSpinePosition(Vector3 spinePosition)
		{
			this.solvers.spine.SetIKPosition(spinePosition);
		}

		// Token: 0x0600012C RID: 300 RVA: 0x00002EF3 File Offset: 0x000010F3
		public void SetSpineWeight(float weight)
		{
			this.solvers.spine.SetIKPositionWeight(weight);
		}

		// Token: 0x0600012D RID: 301 RVA: 0x0001E3FC File Offset: 0x0001C5FC
		public IKSolverLimb GetGoalIK(AvatarIKGoal goal)
		{
			switch (goal)
			{
			case AvatarIKGoal.LeftFoot:
				return this.solvers.leftFoot;
			case AvatarIKGoal.RightFoot:
				return this.solvers.rightFoot;
			case AvatarIKGoal.LeftHand:
				return this.solvers.leftHand;
			case AvatarIKGoal.RightHand:
				return this.solvers.rightHand;
			default:
				return null;
			}
		}

		// Token: 0x0600012E RID: 302 RVA: 0x00002F06 File Offset: 0x00001106
		public void InitiateBipedIK()
		{
			this.InitiateSolver();
		}

		// Token: 0x0600012F RID: 303 RVA: 0x00002F0E File Offset: 0x0000110E
		public void UpdateBipedIK()
		{
			this.UpdateSolver();
		}

		// Token: 0x06000130 RID: 304 RVA: 0x0001E458 File Offset: 0x0001C658
		public void SetToDefaults()
		{
			foreach (IKSolverLimb iksolverLimb in this.solvers.limbs)
			{
				iksolverLimb.SetIKPositionWeight(0f);
				iksolverLimb.SetIKRotationWeight(0f);
				iksolverLimb.bendModifier = IKSolverLimb.BendModifier.Animation;
				iksolverLimb.bendModifierWeight = 1f;
			}
			this.solvers.leftHand.maintainRotationWeight = 0f;
			this.solvers.rightHand.maintainRotationWeight = 0f;
			this.solvers.spine.SetIKPositionWeight(0f);
			this.solvers.spine.tolerance = 0f;
			this.solvers.spine.maxIterations = 2;
			this.solvers.spine.useRotationLimits = false;
			this.solvers.aim.SetIKPositionWeight(0f);
			this.solvers.aim.tolerance = 0f;
			this.solvers.aim.maxIterations = 2;
			this.SetLookAtWeight(0f, 0.5f, 1f, 1f, 0.5f, 0.7f, 0.5f);
		}

		// Token: 0x06000131 RID: 305 RVA: 0x0001E58C File Offset: 0x0001C78C
		public override void FixTransforms()
		{
			this.solvers.lookAt.FixTransforms();
			for (int i = 0; i < this.solvers.limbs.Length; i++)
			{
				this.solvers.limbs[i].FixTransforms();
			}
		}

		// Token: 0x06000132 RID: 306 RVA: 0x0001E5DC File Offset: 0x0001C7DC
		public override void InitiateSolver()
		{
			string empty = string.Empty;
			if (BipedReferences.SetupError(this.references, ref empty))
			{
				Warning.Log(empty, this.references.root, false);
				return;
			}
			this.solvers.AssignReferences(this.references);
			if (this.solvers.spine.bones.Length > 1)
			{
				this.solvers.spine.Initiate(base.transform);
			}
			this.solvers.lookAt.Initiate(base.transform);
			this.solvers.aim.Initiate(base.transform);
			foreach (IKSolverLimb iksolverLimb in this.solvers.limbs)
			{
				iksolverLimb.Initiate(base.transform);
			}
			this.solvers.pelvis.Initiate(this.references.pelvis);
		}

		// Token: 0x06000133 RID: 307 RVA: 0x0001E6CC File Offset: 0x0001C8CC
		public override void UpdateSolver()
		{
			for (int i = 0; i < this.solvers.limbs.Length; i++)
			{
				this.solvers.limbs[i].MaintainBend();
				this.solvers.limbs[i].MaintainRotation();
			}
			this.solvers.pelvis.Update();
			if (this.solvers.spine.bones.Length > 1)
			{
				this.solvers.spine.Update();
			}
			this.solvers.aim.Update();
			this.solvers.lookAt.Update();
			for (int j = 0; j < this.solvers.limbs.Length; j++)
			{
				this.solvers.limbs[j].Update();
			}
		}

		// Token: 0x06000134 RID: 308 RVA: 0x00002F16 File Offset: 0x00001116
		public void LogWarning(string message)
		{
			Warning.Log(message, base.transform, false);
		}

		// Token: 0x04000079 RID: 121
		public BipedReferences references = new BipedReferences();

		// Token: 0x0400007A RID: 122
		public BipedIKSolvers solvers = new BipedIKSolvers();
	}
}
